/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.ana.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author lucas.nunes
 */
@Entity
@Table(name = "QLTTB_METODO_OBTENCAO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "MetodoObtencao.findAll", query = "SELECT m FROM MetodoObtencao m"),
    @NamedQuery(name = "MetodoObtencao.findByMtoId", query = "SELECT m FROM MetodoObtencao m WHERE m.mtoId = :mtoId"),
    @NamedQuery(name = "MetodoObtencao.findByMtoNm", query = "SELECT m FROM MetodoObtencao m WHERE m.mtoNm = :mtoNm"),
    @NamedQuery(name = "MetodoObtencao.findByMtoIcCalculado", query = "SELECT m FROM MetodoObtencao m WHERE m.mtoIcCalculado = :mtoIcCalculado"),
    @NamedQuery(name = "MetodoObtencao.findByMtoDs", query = "SELECT m FROM MetodoObtencao m WHERE m.mtoDs = :mtoDs")})
public class MetodoObtencao implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "MTO_ID")
    private BigDecimal mtoId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 104)
    @Column(name = "MTO_NM")
    private String mtoNm;
    @Basic(optional = false)
    @NotNull
    @Column(name = "MTO_IC_CALCULADO")
    private short mtoIcCalculado;
    @Size(max = 4000)
    @Column(name = "MTO_DS")
    private String mtoDs;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cvhMtoId")
    private List<CaracterizacaoVhm> caracterizacaoVhmList;
    @JoinColumn(name = "MTO_VAR_ID", referencedColumnName = "VAR_ID")
    @ManyToOne
    private Variavel mtoVarId;

    public MetodoObtencao() {
    }

    public MetodoObtencao(BigDecimal mtoId) {
        this.mtoId = mtoId;
    }

    public MetodoObtencao(BigDecimal mtoId, String mtoNm, short mtoIcCalculado) {
        this.mtoId = mtoId;
        this.mtoNm = mtoNm;
        this.mtoIcCalculado = mtoIcCalculado;
    }

    public BigDecimal getMtoId() {
        return mtoId;
    }

    public void setMtoId(BigDecimal mtoId) {
        this.mtoId = mtoId;
    }

    public String getMtoNm() {
        return mtoNm;
    }

    public void setMtoNm(String mtoNm) {
        this.mtoNm = mtoNm;
    }

    public short getMtoIcCalculado() {
        return mtoIcCalculado;
    }

    public void setMtoIcCalculado(short mtoIcCalculado) {
        this.mtoIcCalculado = mtoIcCalculado;
    }

    public String getMtoDs() {
        return mtoDs;
    }

    public void setMtoDs(String mtoDs) {
        this.mtoDs = mtoDs;
    }

    @XmlTransient
    public List<CaracterizacaoVhm> getCaracterizacaoVhmList() {
        return caracterizacaoVhmList;
    }

    public void setCaracterizacaoVhmList(List<CaracterizacaoVhm> caracterizacaoVhmList) {
        this.caracterizacaoVhmList = caracterizacaoVhmList;
    }

    public Variavel getMtoVarId() {
        return mtoVarId;
    }

    public void setMtoVarId(Variavel mtoVarId) {
        this.mtoVarId = mtoVarId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (mtoId != null ? mtoId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MetodoObtencao)) {
            return false;
        }
        MetodoObtencao other = (MetodoObtencao) object;
        if ((this.mtoId == null && other.mtoId != null) || (this.mtoId != null && !this.mtoId.equals(other.mtoId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.gov.ana.service.MetodoObtencao[ mtoId=" + mtoId + " ]";
    }
    
}
